package com.app.megaprosoft.DB;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Types;

import com.app.megaprosoft.general.DateTime;

public class ServicePOSDetail {
	// DB
	Connect con = new Connect(); 
    Connection conn = con.Connect();
    ResultSet rs = null;
	
    DateTime DateTime =new DateTime();
	// POS
	private String OID,
			       UsrOpt,
			       IsActive,
			       IsDeleted,
			      
			       Service_POSOID,
			       Service_POSListOID,
			       Service_ArOID,
			       Service_StartTime,
			       Service_EndTime,
			       
			       Service_Status;
	
	//Get , Set

	
	public String getOID() {
		return OID;
	}

	public void setOID(String oID) {
		OID = oID;
	}

	public String getUsrOpt() {
		return UsrOpt;
	}

	public void setUsrOpt(String usrOpt) {
		UsrOpt = usrOpt;
	}

	public String getIsActive() {
		return IsActive;
	}

	public void setIsActive(String isActive) {
		IsActive = isActive;
	}

	public String getIsDeleted() {
		return IsDeleted;
	}

	public void setIsDeleted(String isDeleted) {
		IsDeleted = isDeleted;
	}

	public String getService_POSOID() {
		return Service_POSOID;
	}

	public void setService_POSOID(String service_POSOID) {
		Service_POSOID = service_POSOID;
	}

	public String getService_POSListOID() {
		return Service_POSListOID;
	}

	public void setService_POSListOID(String service_POSListOID) {
		Service_POSListOID = service_POSListOID;
	}

	public String getService_ArOID() {
		return Service_ArOID;
	}

	public void setService_ArOID(String service_ArOID) {
		Service_ArOID = service_ArOID;
	}

	public String getService_StartTime() {
		return Service_StartTime;
	}

	public void setService_StartTime(String service_StartTime) {
		Service_StartTime = service_StartTime;
	}

	public String getService_EndTime() {
		return Service_EndTime;
	}

	public void setService_EndTime(String service_EndTime) {
		Service_EndTime = service_EndTime;
	}

	public String getService_Status() {
		return Service_Status;
	}

	public void setService_Status(String service_Status) {
		Service_Status = service_Status;
	}

	public ResultSet selectPOSDetail() throws Exception {
        String StrSql = "SELECT " +
		        			"[OID]," +
							"[LastModified]," +
							"[ModifiedBy]," +
							"[CreatedDate]," +
							"[CreatedBy]," +	
							"[IsActive]," +
							"[IsDeleted]," +
							
							"[Service_POSOID]," +
							"[Service_POSListOID]," +
							"[Service_ArOID]," +
							"[Service_StartTime]," +
							"[Service_EndTime]," +
							
							"[Service_Status] " +
          
                  "FROM 	[dbo].[udfCarCare_ServicePOSDetail]() " ;
                
		StrSql += "WHERE 	[IsActive] = '1' " +
				  "AND		[IsDeleted] = '0' ";

		StrSql += "ORDER BY [OID] DESC ";
		//System.out.println(StrSql);
		
		return con.selectData(StrSql);
    }

	public String stpPOSManagement(String OperationType) throws Exception {
		conn = con.Connect();
        java.sql.CallableStatement cstmt = conn.prepareCall("{call stpCarCare_ServicePOSDetailManagement"
                + "("
                + "?,?,?,?,?,"
                + "?,?,?,?,?,"
                + "?,?"
                + ")}");

        try {
            if (conn != null) {
                cstmt.setString(1,  OperationType);
                cstmt.setString(2,  getOID());
                cstmt.setString(3,  getUsrOpt());
                cstmt.setString(4,  getIsActive());
                cstmt.setString(5,  getIsDeleted());

                cstmt.setString(6,  getService_POSOID());
                cstmt.setString(7,  getService_POSListOID());
                cstmt.setString(8,  getService_ArOID());
                cstmt.setString(9,  getService_StartTime());
        		cstmt.setString(10, getService_EndTime());
        		
			    cstmt.setString(11, getService_Status());
			    
                cstmt.registerOutParameter(12, Types.VARCHAR);
                cstmt.execute();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return cstmt.getString(22);
    }

    public void closeConnecttion() throws Exception {
    	 if (conn != null) {
             conn.close();
         }
    }

    public void closeConn() throws Exception {
        conn.close();
    }	
}
